package firstcontent.stack;

/**
 * @Author: fxy
 * @Date: 2022/02/15/15:48
 * @Description: -Xms100m -Xmx100m -XX:+DoEscapeAnalysis -XX:+PrintGC -XX:-EliminateAllocations
 */
public class ScalarReplace {
    public static class User{
        public int id;
        public String name;
    }

    public static void alloc(){
        //未发生逃逸
        User u = new User();
        u.id = 5;
        u.name = "www.com.yun";
    }

    public static void main(String[] args) {
        long start = System.currentTimeMillis();
        for(int i = 0;i<10000000;i++){
            alloc();
        }
        long end = System.currentTimeMillis();
        System.out.println("consume time:"+(end-start)+"ms");
    }
}
